﻿/*

  The contents of this file are subject to the Mozilla Public License Version
  1.1 (the "License"); you may not use this file except in compliance with
  the License. You may obtain a copy of the License at 
  
           http://www.mozilla.org/MPL/ 
  
  Software distributed under the License is distributed on an "AS IS" basis,
  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  for the specific language governing rights and limitations under the License. 
  
  The Original Code is ASGard Framework.
  
  The Initial Developer of the Original Code is
  ALCARAZ Marc (aka eKameleon)  <ekameleon@gmail.com>.
  Portions created by the Initial Developer are Copyright (C) 2004-2009
  the Initial Developer. All Rights Reserved.
  
  Contributor(s) :
  
*/
package examples 
{
    import asgard.display.Background;
    import asgard.display.ShaderLoader;
    import asgard.filters.ReflectionFilter;

    import pegas.draw.FillStyle;

    import flash.display.Sprite;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.media.Camera;
    import flash.media.Video;
    import flash.net.URLRequest;

    /**
     * Test the asgard.filters.ReflectionFilter class, this example work only with a FP10 or sup.
     */
    public class ExampleReflectionFilter extends Sprite 
    {
        public function ExampleReflectionFilter()
        {
            // stage
            
            stage.scaleMode = StageScaleMode.NO_SCALE ;
            
            // container
            
            container = new Background() ;
            
            container.x = 75 ;
            container.y = 60 ;
            
            container.w = 320 ;
            container.h = 295 ;
            
            container.fill = new FillStyle( 0x000000 ) ;
            
            addChild( container ) ;
            
            // video
            
            var video:Video = new Video() ;
            video.attachCamera( Camera.getCamera() ) ;
            
            container.addChild( video ) ;
            
            // shader
            
            loader = new ShaderLoader() ;
            loader.addEventListener( Event.COMPLETE , complete ) ;
            loader.load( new URLRequest( "pbj/Reflection.pbj" ) ) ;
        }
        
        public var container:Background ;
        
        public var filter:ReflectionFilter ;
        
        public var loader:ShaderLoader ;
        
        protected function complete( e:Event ):void
        {
            filter = new ReflectionFilter( loader.shader ) ;
            
            filter.alpha  = 0.5  ; // alpha of the reflection
            filter.size   = 55   ; // size of the reflection
            filter.height = 240  ; // size of the display
            
            container.filters = [ filter ] ;
        }
    }
}
